<?php echo $this->element('displayHeader'); ?>
<div class="toolbar"><?php echo $this->element('toolbar', array('buttons' => array(array('refresh' => array('action' => 'dispatch_search'))))); ?></div>

<?php echo $form->create(null, array('action' => 'dispatch', 'target' => '_blank')); ?>
<fieldset>
    <legend>Criteria</legend>
    <table>
            <tr>
                <td width="100px"><?php echo $form->label('Product.part_no'); ?></td>
                <td width="250px"><?php echo $form->text('Product.part_no'); ?></td>
                <td width="80px" ><?php echo $form->label('Dispatch.customer_id', 'Customer'); ?></td>
                <td><?php echo $form->select('Dispatch.customer_id', $customers, null, null, OPTION_ALL); ?></td>
            </tr>
            <tr>
                <td><?php echo $form->label('Product.category_id', 'Category'); ?></td>
                <td><?php echo $form->select('Product.category_id', $categories, null, null, OPTION_ALL); ?></td>
                <td><?php echo $form->label('Dispatch.site_id', 'Site'); ?></td>
                <td><?php echo $form->select('Dispatch.site_id', null, null, null, OPTION_ALL); ?></td>
            </tr>
            <tr>
                <td class="top"><?php echo $form->label('Product.supplier_id', 'Vendor'); ?></td>
                <td><?php echo $form->select('Product.supplier_id', $suppliers, null, null, OPTION_ALL); ?></td>

            </tr>
            <tr>
                <td><?php echo $form->label('Product.brand_id', 'Brand'); ?></td>
                <td colspan="3"><?php echo $form->select('Product.brand_id', null, null, null, OPTION_ALL); ?></td>

            </tr>
            <tr>
                <td colspan="4"><hr /></td>
            </tr>
            <tr>
                <td class="top"><?php echo $form->label('Dispatch.dispatch_date', 'Dispatch Date'); ?></td>
                <td>
                    From <?php echo $form->text('Dispatch.dispatch_date_start', array('size' => 7, 'class' => 'text-right')); ?>
                    To <?php echo $form->text('Dispatch.dispatch_date_end', array('size' => 7, 'class' => 'text-right')); ?>
                </td>
            </tr>
            <tr>
                <td colspan="4"><hr /></td>
            </tr>
    </table>
    <table>
            <tr>
                <td width="150px"><?php echo $form->label('Option.order1', 'Order by (1st Priority)'); ?></td>
                <td width="250px"><?php echo $form->select('Option.order1', $orderOptions, null, null, false); ?></td>
                <td width="80px"><label>Show as</label></td>
                <td ><?php echo $form->select('Option.seq', $seqOptions, null, null, false); ?></td>
            </tr>
            <tr>
                <td><?php echo $form->label('Option.order2', 'Order by (2nd Priority)'); ?></td>
                <td><?php echo $form->select('Option.order2', $orderOptions, null, null); ?></td>
                <td><label>Show Only</label></td>
                <td>
                    <?php echo $form->text('Option.limit', array('size' => 5, 'class' => 'text-right')); ?> entries
                    <span class="caption">(Leave blank for all.)</span>
                </td>
            </tr>
            <tr>
                <td colspan="4"><hr /></td>
            </tr>
    </table>
    <table>
        <tr>
            <td class="top" width="150px"><?php echo $form->label('display', 'Additional Information'); ?></td>
            <td>
                <?php echo $form->checkbox('Option.display_dispatch_no'); ?>&nbsp;&nbsp;Dispatch no. / Dispatch Date / Product Description<br />
            </td>
        </tr>
    </table>
    <?php echo $this->element('report/buttons', array('action' => 'dispatch', 'button' => array('search', 'print', 'excel'))); ?>
</fieldset>
<?php echo $form->end(); ?>

<script type="text/javascript">
    $j(function() {
        $j.datesearchpicker("#DispatchDispatchDate");
        $j('button').handover();

        $j('#ProductSupplierId').bind('change', function() {
            $j('#ProductBrandId').requestOptions('brands/option_list', $j(this).val(), {empty_option: '--All--'});
        });

        $j('#DispatchCustomerId').bind('change', function() {
            $j('#DispatchSiteId').requestOptions('sites/option_list', $j(this).val(), {empty_option: '--All--'});
        });
    });
</script>
<?php echo $this->element('report/result'); ?>